package com.qf.efserver.track.controller;

import com.qf.common.core.common.R;
import com.qf.efserver.track.param.SaveTrackParam;
import com.qf.efserver.track.service.MotionTrackService;
import com.qf.efserver.track.vo.TrackVO;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Author hehecheng
 * Date 2024/11/16
 * 祝我们都能遇见真诚的人
 * 见字如面
 */
@RestController
@RequestMapping("/track")
@Api(tags = "运动轨迹")
public class MotionTrackController {

    @Resource
    private MotionTrackService motionTrackService;

    /**
     * 记录运动轨迹
     *
     * @param saveTrackParam
     * @return
     */
    @PostMapping("/save")
    @ApiOperation(value = "记录运动轨迹接口",
            notes = "记录运动轨迹的经纬度, 当tag属性为0时，表示开始运动，1时表示运动中，2表示结束运动; " +
                    "活动id,activityId,当tag为0时，为0或null,后续为具体的活动id")
    public R<Integer> saveTrack(@RequestBody SaveTrackParam saveTrackParam) {
        Integer id = motionTrackService.saveTrack(saveTrackParam);
        return R.ok(id);
    }

    /**
     * 获取历史活动轨迹
     *
     * @param activityId
     * @return
     */
    @PostMapping("/historical")
    @ApiOperation(value = "获取用户历史活动的轨迹", notes = "展示用户自定义的食物")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "成功", response = TrackVO.class, responseContainer = "List"),
    })
    @ApiParam(name = "activityId", value = "活动id")
    public R<List<TrackVO>> getHistoricalTracks(@RequestParam Integer activityId) {
        List<TrackVO> trackVOS = motionTrackService.getHistoricalTracks(activityId);
        return R.ok(trackVOS);
    }
}
